package cn.bjxy.shishaolong.system.profession_course.service;

import cn.bjxy.shishaolong.system.profession_course.entity.Course;
import cn.bjxy.shishaolong.system.profession_course.mapper.CourseMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 时少龙
 * @since 2019-03-12
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements ICourseService {

    @Override
    public IPage<Course> queryByCondition(IPage<Course> page, Course course) {
        // 查询条件为空
        if(course == null || StringUtils.isEmpty(course.getCourseName())){
            return this.page(page);
        }
        // 按条件查询
        return this.page(page,new QueryWrapper<Course>().lambda()
                .like(Course::getCourseName,course.getCourseName()));
    }

    @Override
    public List<Course> queryByCondition(Course course) {
        // 查询条件为空
        if(course == null || StringUtils.isEmpty(course.getCourseName())){
            return this.list();
        }
        // 按条件查询
        return this.list(new QueryWrapper<Course>().lambda()
                .like(Course::getCourseName,course.getCourseName()));
    }
}
